package dp;

/**
 * @author : Rookie
 * @description : 斐波那契数列
 * @date : 2023/6/15
 */
public class FibonacciSeq {

    public static void main(String[] args) {
        int n = 10;
        long res = fibonacci(n);
        System.out.println(res);
    }

    private static long fibonacci(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        long[] dp = new long[n+1];
        dp[0] = 0;
        dp[1] = 1;
        for (int i = 2; i <= n; i++) {
            dp[i] = dp[i-1] + dp[i-2];
        }
        return dp[n];
    }
}
